package com.zhoutao.blog.seven.api;

import com.zhoutao.blog.seven.model.Response;
import com.zhoutao.blog.seven.model.request.AdminLoginRequest;
import com.zhoutao.blog.seven.service.AdminService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/user")
public class UserController {

    private final AdminService adminService;


    public UserController(AdminService adminService) {
        this.adminService = adminService;
    }

    @PostMapping
    public Response<String> login(@RequestBody AdminLoginRequest request) {
        Long tokenId = adminService.login(request.getUsername(), request.getPassword());
        return Response.success(String.valueOf(tokenId));
    }
}
